<template>
  <div class="main">
    <div class="summOut">
      <Scroller lock-x>
        <div class="ouerImgWrap">
          <span class="posBack" @click="backToPrev">
            <img class="posImg" src="~/static/images/top_icon_back1.png" alt />
          </span>

          <img
            class="summImg"
            src="https://static.shengxue985.com/sxzx_app/h5/activity/sycp-home.jpg"
            alt
          />
          <div style="height: 1.5rem;"></div>
        </div>
      </Scroller>
      <div
        class="fixadBot has-bottombar"
        :style="commonJs.checkTerminal()==='ios'?'height: 1.5rem;':''"
      >
        <span @click="gotos">进入生涯测评</span>
      </div>
    </div>

    <LoginVerification
      :isShowModal="isShowModal"
      v-on:fromChildloginVerification="loginVers"
      headTitle="生涯测评服务"
    ></LoginVerification>
  </div>
</template>
<script>
import ls from "store2";
import { Scroller } from "vux";
import { getReportList } from "~/api/evaluation";
import { identityLogin } from "~/api/identity";
import LoginVerification from "~/components/LoginVerification";
import { constants } from "crypto";
import { backAppOrWx } from "~/common/common";
export default {
  head: {
    title: "生涯测评"
  },
  components: {
    Scroller,
    LoginVerification
  },
  data() {
    return {
      isShowModal: false,
      toke: "",
      surplus: 0
    }; 
  },
  created() {
    this.commonJs.accectAppParame();
  },
  mounted: function() {
    if (ls.get("yxkData")) {} else { this.isShowModal = true; }
  },

  watch: {},
  methods: {
    //查看卡劵是否生成方案
    loginVers(data) {
     identityLogin(data)
        .then(res => {
          if (res.code === "0") {
            let usersData = res.data;
            ls.set("yxkData", usersData);
            ls.set("userType", usersData.userType);
            ls.set("tokens", usersData.accessToken);
            this.isShowModal = false;
            this.$vux.toast.text("服务授权成功");
        
          } else {
            this.$vux.toast.text(res.message);
          }
        })
        .catch(error => {
          this.$vux.toast.text(error);
        });
    },
    backToPrev() {
      backAppOrWx()
    },

    goTeaIndexUrl() {
      let abc = window.location.href;

      this.jumpUrl = decodeURIComponent(
        this.commonJs.GetUrlParam("tea_return_url")
      );
      if (this.jumpUrl) {
        ls.set("jumpsTeaUrl", this.jumpUrl);
        let datas = this.commonJs.GetUrlParam("tea_userData");
        let usersData = JSON.parse(decodeURIComponent(datas));
        ls.set("yxkData", usersData);
        ls.set("userType", usersData.userType);
        ls.set("tokens", usersData.accessToken);
      }
    },

    getReportList() { 
      this.$vux.loading.show();
      let userid = ls.get("yxkData").userId * 1;
      ls.set("userId", userid);
      getReportList(ls.get("userType"))
        .then(res => {
          if (res.code === "0") {
            let length = res.data.length;
     
            if (length) {
              this.commonJs.gopush("reportRecord");
            } else {
              this.commonJs.gopush("evaluationEntry");
            }
          }
          this.$vux.loading.hide();
        })
        .catch(error => {
          this.$vux.toast.text(error);
          this.$vux.loading.hide();
        });
    },
    gotos() {
      ls.set("preUrl", "../evaluation/ad");
      this.getReportList()
    },

  },
  beforeDestroy() {}
};
</script>

<style scoped lang="less">
.ouerImgWrap {
  width: 7.5rem;
  height: auto;
  position: relative;

  .posBack {
    position: absolute;
    width: 0.8rem;
    height: 0.8rem;
    left: 0.2rem;
    top: 0.2rem;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;

    .posImg {
      display: block;
      width: 0.5rem;
      height: 0.5rem;
      margin: 0.15rem auto;
    }
  }
}

.fixadBot {
  width: 7.5rem;
  overflow: hidden;
  position: fixed;
  height: 1.5rem;
  max-height: 2rem;
  bottom: 0rem;
  z-index: 100;

  span {
    display: block;
    width: 3.2rem;
    height: 0.8rem;
    background: @mainColor;
    border-radius: 0.1rem;
    font-size: 0.36rem;

    font-weight: 600;
    color: rgba(255, 255, 255, 1);
    line-height: 0.8rem;
    text-align: center;
    margin: 0.2rem auto 0.2rem;
  }
}

.summOut {
  width: 7.5rem;
  height: auto;
  min-height: 16.24rem;
  background: #fff;
}

.summImg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 16.24rem;
}
</style>
